/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: FruitMeal
 * Author:   zhouheng
 * Date:     2019/5/1 13:30
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.zhouh.patterns.com.zhouh.create.builder;

import com.zhouh.patterns.com.zhouh.entity.fruit.Apple;
import com.zhouh.patterns.com.zhouh.entity.fruit.Banana;
import com.zhouh.patterns.com.zhouh.entity.fruit.Orange;
import lombok.Setter;

import java.security.PublicKey;

/**
 * 〈一句话功能简述〉<br> 
 * 〈套餐对象〉
 *
 * @author zhouheng
 * @create 2019/5/1
 * @since 1.0.0
 */
@Setter
public class FruitMeal {
    private Banana banana;
    private Apple apple;
    private Orange orange;
    private int discount;//折扣价
    private int totalPrice;//套餐总价

    public void init() {
        if (null != apple){
            totalPrice += apple.getPrice();
        }
        if (null != orange){
            totalPrice += orange.getPrice();
        }
        if (null != banana){
            totalPrice += banana.getPrice();
        }
        if (totalPrice > 0){
            totalPrice -= discount;
        }
    }

    public int cost(){
        return this.totalPrice;
    }

    public void showItems() {
        System.out.println("applePrice: " + apple.getPrice());
        System.out.println("orangePrice: " + orange.getPrice());
        System.out.println("bananaPrice: " + banana.getPrice());
        System.out.println("totalPrice：" + cost());
    }
}